AHardwareBuffer_UsageFlags

Buffer usage flags, specifying how the buffer will be accessed.

Values

ValueMeaning
AHARDWAREBUFFER_USAGE_CPU_READ_NEVER0UL

The buffer will never be locked for direct CPU reads using the AHardwareBuffer_lock() function. Note that reading the buffer using OpenGL or Vulkan functions or memory mappings is still allowed.

AHARDWAREBUFFER_USAGE_CPU_READ_RARELY2UL

The buffer will sometimes be locked for direct CPU reads using the AHardwareBuffer_lock() function. Note that reading the buffer using OpenGL or Vulkan functions or memory mappings does not require the presence of this flag.

AHARDWAREBUFFER_USAGE_CPU_READ_OFTEN3UL

The buffer will often be locked for direct CPU reads using the AHardwareBuffer_lock() function. Note that reading the buffer using OpenGL or Vulkan functions or memory mappings does not require the presence of this flag.

AHARDWAREBUFFER_USAGE_CPU_READ_MASK0xFUL

CPU read value mask.

AHARDWAREBUFFER_USAGE_CPU_WRITE_NEVER0UL << 4

The buffer will never be locked for direct CPU writes using the AHardwareBuffer_lock() function. Note that writing the buffer using OpenGL or Vulkan functions or memory mappings is still allowed.

AHARDWAREBUFFER_USAGE_CPU_WRITE_RARELY2UL << 4

The buffer will sometimes be locked for direct CPU writes using the AHardwareBuffer_lock() function. Note that writing the buffer using OpenGL or Vulkan functions or memory mappings does not require the presence of this flag.

AHARDWAREBUFFER_USAGE_CPU_WRITE_OFTEN3UL << 4

The buffer will often be locked for direct CPU writes using the AHardwareBuffer_lock() function. Note that writing the buffer using OpenGL or Vulkan functions or memory mappings does not require the presence of this flag.

AHARDWAREBUFFER_USAGE_CPU_WRITE_MASK0xFUL << 4

CPU write value mask.

AHARDWAREBUFFER_USAGE_GPU_SAMPLED_IMAGE1UL << 8

The buffer will be read from by the GPU as a texture.

AHARDWAREBUFFER_USAGE_GPU_FRAMEBUFFER1UL << 9

The buffer will be written to by the GPU as a framebuffer attachment.

AHARDWAREBUFFER_USAGE_GPU_COLOR_OUTPUTAHARDWAREBUFFER_USAGE_GPU_FRAMEBUFFER

The buffer will be written to by the GPU as a framebuffer attachment.

Note that the name of this flag is somewhat misleading: it does not imply that the buffer contains a color format. A buffer with depth or stencil format that will be used as a framebuffer attachment should also have this flag. Use the equivalent flag AHARDWAREBUFFER_USAGE_GPU_FRAMEBUFFER to avoid this confusion.

AHARDWAREBUFFER_USAGE_COMPOSER_OVERLAY1UL << 11

The buffer will be used as a composer HAL overlay layer.

This flag is currently only needed when using ASurfaceTransaction_setBuffer to set a buffer. In all other cases, the framework adds this flag internally to buffers that could be presented in a composer overlay. ASurfaceTransaction_setBuffer is special because it uses buffers allocated directly through AHardwareBuffer_allocate instead of buffers allocated by the framework.

AHARDWAREBUFFER_USAGE_PROTECTED_CONTENT1UL << 14

The buffer is protected from direct CPU access or being read by non-secure hardware, such as video encoders.

This flag is incompatible with CPU read and write flags. It is mainly used when handling DRM video. Refer to the EGL extension EGL_EXT_protected_content and GL extension GL_EXT_protected_textures for more information on how these buffers are expected to behave.

AHARDWAREBUFFER_USAGE_VIDEO_ENCODE1UL << 16

The buffer will be read by a hardware video encoder.

AHARDWAREBUFFER_USAGE_SENSOR_DIRECT_DATA1UL << 23

The buffer will be used for direct writes from sensors. When this flag is present, the format must be AHARDWAREBUFFER_FORMAT_BLOB.

AHARDWAREBUFFER_USAGE_GPU_DATA_BUFFER1UL << 24

The buffer will be used as a shader storage or uniform buffer object. When this flag is present, the format must be AHARDWAREBUFFER_FORMAT_BLOB.

AHARDWAREBUFFER_USAGE_GPU_CUBE_MAP1UL << 25

The buffer will be used as a cube map texture. When this flag is present, the buffer must have a layer count that is a multiple of 6. Note that buffers with this flag must be bound to OpenGL textures using the extension GL_EXT_EGL_image_storage instead of GL_KHR_EGL_image.

AHARDWAREBUFFER_USAGE_GPU_MIPMAP_COMPLETE1UL << 26

The buffer contains a complete mipmap hierarchy. Note that buffers with this flag must be bound to OpenGL textures using the extension GL_EXT_EGL_image_storage instead of GL_KHR_EGL_image.

AHARDWAREBUFFER_USAGE_VENDOR_01UL << 28
AHARDWAREBUFFER_USAGE_VENDOR_11UL << 29
AHARDWAREBUFFER_USAGE_VENDOR_21UL << 30
AHARDWAREBUFFER_USAGE_VENDOR_31UL << 31
AHARDWAREBUFFER_USAGE_VENDOR_41UL << 48
AHARDWAREBUFFER_USAGE_VENDOR_51UL << 49
AHARDWAREBUFFER_USAGE_VENDOR_61UL << 50
AHARDWAREBUFFER_USAGE_VENDOR_71UL << 51
AHARDWAREBUFFER_USAGE_VENDOR_81UL << 52
AHARDWAREBUFFER_USAGE_VENDOR_91UL << 53
AHARDWAREBUFFER_USAGE_VENDOR_101UL << 54
AHARDWAREBUFFER_USAGE_VENDOR_111UL << 55
AHARDWAREBUFFER_USAGE_VENDOR_121UL << 56
AHARDWAREBUFFER_USAGE_VENDOR_131UL << 57
AHARDWAREBUFFER_USAGE_VENDOR_141UL << 58
AHARDWAREBUFFER_USAGE_VENDOR_151UL << 59
AHARDWAREBUFFER_USAGE_VENDOR_161UL << 60
AHARDWAREBUFFER_USAGE_VENDOR_171UL << 61
AHARDWAREBUFFER_USAGE_VENDOR_181UL << 62
AHARDWAREBUFFER_USAGE_VENDOR_191UL << 63

Meta